package ui.juego

import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.layout.ColumnLayout
import java.awt.Color
import org.uqbar.arena.widgets.Button
import ui.juego.utilidades.IconUtils

class JuegoTerminadoDialog extends Dialog<JuegoTerminado> {
	
	new(WindowOwner owner, JuegoTerminado model) {
		super(owner, model)
		title = '''«modelObject.investigacion.caso.nombre» - Resuelto'''
		iconImage = IconUtils.path
	}
	
	override protected createFormPanel(Panel mainPanel) {}
	
	override createMainTemplate(Panel mainPanel) {
		if(modelObject.buenasNoticias)
			createBuenasNoticiasPanel(mainPanel)
		else createMalasNoticiasPanel(mainPanel)
	}
	
	def createBuenasNoticiasPanel(Panel owner) {
		val buenasPanel = new Panel(owner) => [
			layout = new VerticalLayout
		]
		val headPanel = new Panel(buenasPanel) => [
			layout = new ColumnLayout(2)
		]
		new Label(headPanel) => [
			text = "En hora buena!!!"
			fontSize = 14
		]
		new Label(headPanel) => [
			width = 200
		]
		new Label(buenasPanel) => [
			text = '''Ha detenido a «modelObject.investigacion.caso.responsable.nombre» y recuperado el objecto robado («modelObject.investigacion.caso.objetoRobado»)'''
			fontSize = 14
		]
		new Label(buenasPanel) => [
			text = "Felicitaciones!!!"
			foreground = Color.GREEN.darker
			fontSize = 18
		]
	
		new Label(buenasPanel) => [
			heigth = 30
		]
		
		new Button(buenasPanel) => [
			caption = "Disfrutar de nuestra victoria"
			width = 180
			onClick[ | 
				close
				new ImagenFinal(true).setVisible(true)
			]
		]
		
	}
	
	def createMalasNoticiasPanel(Panel owner) {
		val malasPanel = new Panel(owner) => [
			layout = new VerticalLayout
		]
		val headPanel = new Panel(malasPanel) => [
			layout = new ColumnLayout(2)
		]
		new Label(headPanel) => [
			text = "Malas noticias =("
			foreground = Color.RED
			fontSize = 14
		]
		new Label(headPanel) => [
			width = 200
		]
		new Label(malasPanel) => [
			text = '''Ha detenido a «modelObject.investigacion.caso.responsable.nombre», pero usted tenia una orden contra «modelObject.investigacion.ordenDeArresto.responsable.nombre»'''
			fontSize = 14
		]
		new Label(malasPanel) => [
			text = "Lamentablemente este crimen quedará impune"
			fontSize = 14
		]
		new Label(malasPanel) => [
			heigth = 30
		]
		
		new Button(malasPanel) => [
			caption = "Aceptar el error cometido"
			width = 180
			onClick[ | 
				close
				new ImagenFinal(false).setVisible(true)
			]
		]
	}
	
	
}